import $ from '../common';

Page({
  data: {
    page:1,
    info:[],
    tip:'上滑加载更多'
  },
  onLoad(e) {
    wx.getSystemInfo({
      success: res => {
        let winWidth = res.windowWidth
        let otherWidth = Math.floor((winWidth - 80) / 4)
        this.setData({
          otherWidth
        })
      },
    })
    this.getinfo()
  },
  onShow() {

  },
  getinfo(){
    $.get('/user/feedback/list',{
      zonecode:wx.getStorageSync('addresscode') || '',
      page:this.data.page,
      limit:20,
    },res=>{
      if(res.feedbacks.length<20){
        this.data.tip='已经到底了'
      }else{
        this.data.tip='上滑加载更多'
      }
      this.data.page++
      this.setData({
        info:[...this.data.info,...res.feedbacks],
        tip:this.data.tip,
        page:this.data.page
      })
    })
  },
  onReachBottom(){
    console.log('触底了!!!');
    this.getinfo()
  }
})